<template>
   <div class="header">
    <h1>我是Header</h1>
 <p>Count的值是{{ count }},电影的列表总长度是{{ movieList.length }}</p>
    <p>价格是{{ price }}</p>

    <button @click='increment'>累加count的值</button>
    <button @click="incrementN({ n: 3 })">count的值每次加n</button>
    <button @click="incrementWait">等一等再加</button>
     <button @click="incrementNWait({ n: 5 })">等一等再加n</button>
  </div>
</template>

<script>
import { mapState,mapMutations ,mapActions} from "vuex";
export default {
    computed : {
        ...mapState(['count','price'])
    },
    methods: {
        ...mapMutations(["increment", "incrementN"]),

        incrementWait(){
            setTimeout(() => {
                this.$store.commit("increment");
            }, 2000);
        },
         ...mapActions(["incrementWait", "incrementNWait"]),
    }
}
</script>

<style>
.header {
  margin: 30px;
  background: yellowgreen;
}
</style>